package com.ysh.gsm;

import java.io.Serializable;
import java.util.Arrays;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author ysh
 *
 */
@Embeddable
public class MrHistoryPK implements Serializable{


	private static final long serialVersionUID = -5565467586013199346L;
	
	private byte mrType;
	private TimeDimension timeDimension;
	private byte cellId;
	private short mrValue;
	
	@Id	
	@Column(name = "mr_type", nullable = false)
	public byte getMrType() {
		return mrType;
	}
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "time_key", referencedColumnName = "time_key", nullable = false, insertable = false, updatable = false)
	public TimeDimension getTimeDimension() {
		return timeDimension;
	}
	@Id	
	@Column(name = "cell_id", nullable = false)
	public byte getCellId() {
		return cellId;
	}
	@Id	
	@Column(name = "mr_value", nullable = false)
	public short getMrValue() {
		return mrValue;
	}
	public void setMrType(byte mrType) {
		this.mrType = mrType;
	}
	public void setTimeDimension(TimeDimension timeDimension) {
		this.timeDimension = timeDimension;
	}
	public void setCellId(byte cellId) {
		this.cellId = cellId;
	}
	public void setMrValue(short mrValue) {
		this.mrValue = mrValue;
	}
	
	public int hashCode() {
		 return Arrays.hashCode(new Object[] {
				 mrType, timeDimension, cellId,mrValue
			    });
	}

	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if (!(obj instanceof MrHistoryPK)) {
			return false;
		}
		if (null == obj) {
			return false;
		}
		MrHistoryPK pk = (MrHistoryPK) obj;
		return (pk.timeDimension == timeDimension && pk.cellId == cellId&&pk.mrType==mrType&&pk.mrValue==mrValue);
	}

}
